package com.xlh.virtualization.dao.helper;

import com.xlh.virtualization.dao.ConfigMapper;
import com.xlh.virtualization.domain.Config;
import com.xlh.virtualization.domain.example.ConfigExample;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author cheer
 */
@Repository
public class ConfigMapperHelper {

    @Autowired
    private ConfigMapper configMapper;

    /**
     * 查询虚拟化配置
     *
     * @return 虚拟化配置信息
     */
    public Config getConfig() {
        ConfigExample example = new ConfigExample();
        example.or().andDeletedEqualTo(false);
        List<Config> configs = configMapper.selectByExample(example);
        if (CollectionUtils.isNotEmpty(configs)) {
            return configs.get(0);
        }
        return null;
    }
}
